Products Reviews: Analyzing unstructured text

Data scientists are often faced with data sets that contain unstructured text in product review data, and must employ natural language processing (NLP) techniques in order to make it useful. Sentiment analysis refers to the use of NLP techniques to extract subjective information such as the polarity of the text, e.g., whether or not the author is speaking positively or negatively about some topic.

Companies often have useful data which are hidden in large volumes of text such as:

  • online reviews
  • social media posts and tweets
  • interactions with customers, such as emails and call center transcripts

For example, when shopping it can be challenging to decide between products with the same star rating. When this happens, shoppers often sift through the raw text of reviews to understand the strengths and weaknesses of each option.

In this short note, we will show how to use GraphLab Create's sentiment_analysis toolkit to apply pre-trained models to predict sentiment for text data in these situations. More specifically, we are going to automate the task of determining product strengths and weaknesses from review text by following the steps below:

  1. Split the provided Amazon review text into sentences and applying a sentiment analysis model
  2. Tag documents that mention aspects of interest
  3. extract adjectives from raw text, and compare their use in positive and negative reviews
  4. summarizing the use of adjectives for tagged documents

Finally, we will also show how to use the GraphLab Create's product_sentiment toolkit to summarize sentiment about products within reviews written by happy and/or unhappy customers. The products and aspects of interest will be the same as before to help comparisons and conclusions.

Important Note:

GraphLab Create includes feature engineering objects that leverage spaCy, a high performance NLP package. Here we use it for extracting parts of speech and parsing reviews into sentences.

Fire Up GraphLab Create


In [1]:
import graphlab as gl

Feature engineering: Applying NLP Pipeline


In [2]:
def nlp_pipeline(reviews, title, aspects):
    
    from graphlab.toolkits.text_analytics import trim_rare_words, split_by_sentence, extract_parts_of_speech, stopwords, PartOfSpeech
    
    print(title)
    
    print('1. Get reviews for this product')
    reviews = reviews.filter_by(title, 'name')

    print('2. Splitting reviews into sentences')
    reviews['sentences'] = split_by_sentence(reviews['review'])
    sentences = reviews.stack('sentences', 'sentence').dropna()

    print('3. Tagging relevant reviews')
    tags = gl.SFrame({'tag': aspects})
    tagger_model = gl.data_matching.autotagger.create(tags, verbose=False)
    tagged = tagger_model.tag(sentences, query_name='sentence', similarity_threshold=.3, verbose=False)\
                         .join(sentences, on='sentence')

    print('4. Extracting adjectives')
    tagged['cleaned']    = trim_rare_words(tagged['sentence'], stopwords=list(stopwords()))
    tagged['adjectives'] = extract_parts_of_speech(tagged['cleaned'], [PartOfSpeech.ADJ])

    print('5. Predicting sentence-level sentiment')
    model = gl.sentiment_analysis.create(tagged, target=None, features=['review'])
    tagged['sentiment']  = model.predict(tagged)
    return tagged

In [3]:
reviews = gl.SFrame('./amazon_baby.gl/')


2016-05-25 17:57:38,245 [INFO] graphlab.cython.cy_server, 176: GraphLab Create v1.9 started. Logging: /tmp/graphlab_server_1464188254.log
This non-commercial license of GraphLab Create is assigned to tgrammat@gmail.com and will expire on September 21, 2016. For commercial licensing options, visit https://dato.com/buy/.

In [4]:
reviews


Out[4]:
name review rating
Planetwise Flannel Wipes These flannel wipes are
OK, but in my opinion ...
3.0
Planetwise Wipe Pouch it came early and was not
disappointed. i love ...
5.0
Annas Dream Full Quilt
with 2 Shams ...
Very soft and comfortable
and warmer than it ...
5.0
Stop Pacifier Sucking
without tears with ...
This is a product well
worth the purchase. I ...
5.0
Stop Pacifier Sucking
without tears with ...
All of my kids have cried
non-stop when I tried to ...
5.0
Stop Pacifier Sucking
without tears with ...
When the Binky Fairy came
to our house, we didn't ...
5.0
A Tale of Baby's Days
with Peter Rabbit ...
Lovely book, it's bound
tightly so you may no ...
4.0
Baby Tracker® - Daily
Childcare Journal, ...
Perfect for new parents.
We were able to keep ...
5.0
Baby Tracker® - Daily
Childcare Journal, ...
A friend of mine pinned
this product on Pinte ...
5.0
Baby Tracker® - Daily
Childcare Journal, ...
This has been an easy way
for my nanny to record ...
4.0
[183531 rows x 3 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.

Focus on chosen aspects about baby monitors

First, we import helper function from helper_util.py file.


In [5]:
from helper_util import *

Next, we collect the baby monitor reviews:


In [6]:
reviews = search(reviews, 'monitor')


Tokenizing...
TF-IDF transform...
Creating inverted index...
Creating query expansion model...
Saving data for querying...

In [7]:
reviews.print_rows(num_rows=100,max_row_width=300)


+-------------------------------+-------------------------------+--------+
|              name             |             review            | rating |
+-------------------------------+-------------------------------+--------+
| Baby Monitor - Direct Link... | Considering how horrible t... |  3.0   |
| Graco ultraclear baby monitor | Only being able to compare... |  5.0   |
| Graco ultraclear baby monitor | I am currently looking for... |  1.0   |
| Graco ultraclear baby monitor | Love this monitor!  This m... |  5.0   |
| Graco ultraclear baby monitor | I can't tell you how clear... |  5.0   |
| Graco ultraclear baby monitor | After reading the reviews ... |  5.0   |
| Graco ultraclear baby monitor | I'm a fan of Graco product... |  5.0   |
| Graco ultraclear baby monitor | After trying 2 other monit... |  5.0   |
|   900mhz Attachable Monitor   | First the pros:1.  The ran... |  2.0   |
|   900mhz Attachable Monitor   | I have had my monitor for ... |  5.0   |
|   900mhz Attachable Monitor   | I love this monitor. I can... |  5.0   |
|   900mhz Attachable Monitor   | As a electrical engineer a... |  1.0   |
|   900mhz Attachable Monitor   | Unless you are listening f... |  2.0   |
| Fisher-Price Aquarium Monitor | This monitor is a great id... |  2.0   |
| Fisher-Price Aquarium Monitor | This monitor was terrible!... |  2.0   |
| Fisher-Price Aquarium Monitor | I BOUGHT THIS MONITOR THIN... |  1.0   |
| Fisher-Price Aquarium Monitor | This monitor is horrible a... |  1.0   |
| Fisher-Price Aquarium Monitor | I recieved this monitor as... |  4.0   |
| Fisher-Price Aquarium Monitor | Great concept but really b... |  1.0   |
| Fisher-Price Aquarium Monitor | I was disappointed to find... |  1.0   |
| Fisher-Price Aquarium Monitor | My husband and I bought th... |  1.0   |
| Fisher-Price Aquarium Monitor | This monitor is horrible a... |  1.0   |
| Fisher-Price Aquarium Monitor | I LOVE THIS LIGHT SHOW!  M... |  5.0   |
| Fisher-Price Aquarium Monitor | I am incredibly disappoint... |  1.0   |
| Fisher-Price Aquarium Monitor | Even though I had read poo... |  1.0   |
|     So Close Crib Monitor     | I think this monitor is ex... |  4.0   |
|     So Close Crib Monitor     | My husband and I bought th... |  1.0   |
|    Graco Decor Baby Monitor   | This is a good baby monito... |  5.0   |
|  Samsung Ezview Baby Monitor  | So, like a fellow reviewer... |  4.0   |
|  Samsung Ezview Baby Monitor  | I love this monitor. Discr... |  5.0   |
|  Samsung Ezview Baby Monitor  | This monitor is great. I l... |  5.0   |
|  Samsung Ezview Baby Monitor  | My mother purchased this m... |  1.0   |
|  Samsung Ezview Baby Monitor  | Had this monitor for 2 yea... |  2.0   |
|  Samsung Ezview Baby Monitor  | This product worked at fir... |  1.0   |
|  Samsung Ezview Baby Monitor  | We received this monitor a... |  1.0   |
|  Samsung Ezview Baby Monitor  | We were given this monitor... |  4.0   |
|  Samsung Ezview Baby Monitor  | We received the monitor, S... |  1.0   |
|  Samsung Ezview Baby Monitor  | I just wanted to point out... |  3.0   |
|  Samsung Ezview Baby Monitor  | We received this as a gift... |  2.0   |
|    Snuza Baby Monitor, Hero   | I really wanted to like th... |  2.0   |
|    Snuza Baby Monitor, Hero   | I have no insights as to w... |  5.0   |
|    Snuza Baby Monitor, Hero   | I can finally sleep when m... |  5.0   |
|    Snuza Baby Monitor, Hero   | Read about this item to mo... |  5.0   |
|    Snuza Baby Monitor, Hero   | After having a premature b... |  5.0   |
|    Snuza Baby Monitor, Hero   | We bought one for each of ... |  3.0   |
|    Snuza Baby Monitor, Hero   | If the battery lasted long... |  2.0   |
|    Snuza Baby Monitor, Hero   | The monitor has put my min... |  5.0   |
|    Snuza Baby Monitor, Hero   | It sounded good in concept... |  2.0   |
|    Snuza Baby Monitor, Hero   | This little thing is SO do... |  5.0   |
|    Snuza Baby Monitor, Hero   | Love it! Gives me peace of... |  5.0   |
|    Snuza Baby Monitor, Hero   | We got nothing but false a... |  1.0   |
|    Snuza Baby Monitor, Hero   | This is what folks should ... |  5.0   |
|    Snuza Baby Monitor, Hero   | We loved the simplicity of... |  4.0   |
|    Snuza Baby Monitor, Hero   | I love this product and us... |  4.0   |
|    Snuza Baby Monitor, Hero   | I purchased this little mo... |  5.0   |
|    Snuza Baby Monitor, Hero   | Monitor:We had no major pr... |  5.0   |
|    Snuza Baby Monitor, Hero   | Whether it is just a place... |  5.0   |
|    Snuza Baby Monitor, Hero   | I bought this product beca... |  5.0   |
|    Snuza Baby Monitor, Hero   | This has helped me turn my... |  5.0   |
|    Snuza Baby Monitor, Hero   | I finally decided to use t... |  5.0   |
|    Snuza Baby Monitor, Hero   | I read a lot of reviews be... |  4.0   |
|    Snuza Baby Monitor, Hero   | I gave this as a gift to a... |  5.0   |
|    Snuza Baby Monitor, Hero   | Best investment ever! With... |  5.0   |
|    Snuza Baby Monitor, Hero   | Our baby had really bad re... |  5.0   |
|    Snuza Baby Monitor, Hero   | As new, first-time parents... |  5.0   |
|    Snuza Baby Monitor, Hero   | My baby was ten weeks earl... |  5.0   |
|    Snuza Baby Monitor, Hero   | Fabulous item. I'm a first... |  5.0   |
|    Snuza Baby Monitor, Hero   | This item is a must have!!... |  5.0   |
|    Snuza Baby Monitor, Hero   | Almost every night there w... |  2.0   |
|    Snuza Baby Monitor, Hero   | So my daughter is a tummy ... |  5.0   |
|    Snuza Baby Monitor, Hero   | We love the Snuza, it real... |  4.0   |
|    Snuza Baby Monitor, Hero   | Best $100 we've ever spent... |  5.0   |
|    Snuza Baby Monitor, Hero   | We tried to use this devic... |  1.0   |
|    Snuza Baby Monitor, Hero   | I swear if I could only ke... |  5.0   |
|    Snuza Baby Monitor, Hero   | Got this for my 3 mos son.... |  5.0   |
|    Snuza Baby Monitor, Hero   | I purchased this Item afte... |  5.0   |
|    Snuza Baby Monitor, Hero   | This is a great product an... |  5.0   |
|    Snuza Baby Monitor, Hero   | My little guy only likes t... |  5.0   |
|    Snuza Baby Monitor, Hero   | I have used the Snuza Hero... |  5.0   |
|    Snuza Baby Monitor, Hero   | Three words: Peace of Mind... |  5.0   |
|    Snuza Baby Monitor, Hero   | The reason I say you canno... |  5.0   |
|    Snuza Baby Monitor, Hero   | My wife and I are Having A... |  5.0   |
|    Snuza Baby Monitor, Hero   | I have not used the produc... |  3.0   |
|    Snuza Baby Monitor, Hero   | The idea is good since the... |  2.0   |
|    Snuza Baby Monitor, Hero   | I was struggling to put my... |  5.0   |
|    Snuza Baby Monitor, Hero   | After I had my son I was a... |  5.0   |
|    Snuza Baby Monitor, Hero   | My son has worn this every... |  5.0   |
|    Snuza Baby Monitor, Hero   | This is a great product an... |  4.0   |
|    Snuza Baby Monitor, Hero   | We set up our room with an... |  5.0   |
|    Snuza Baby Monitor, Hero   | I was hesitant at first to... |  5.0   |
|    Snuza Baby Monitor, Hero   | This is my first review of... |  5.0   |
|    Snuza Baby Monitor, Hero   | Although I've had some fal... |  5.0   |
|    Snuza Baby Monitor, Hero   | I had to play with it for ... |  5.0   |
|    Snuza Baby Monitor, Hero   | My daughter's pediatrician... |  5.0   |
|    Snuza Baby Monitor, Hero   | Purchased this for my frie... |  5.0   |
|    Snuza Baby Monitor, Hero   | This is the older version,... |  5.0   |
| 900MHz Baby Monitor 900MHz... | Super quiet unlike other m... |  5.0   |
|    Lorex Video Baby Monitor   | Bought months ago and have... |  4.0   |
+-------------------------------+-------------------------------+--------+
[98 rows x 3 columns]


In [8]:
for review in reviews['review'][0:10]:
    print review, '\n'


Considering how horrible the selection is these days for choosing a quality baby monitor that doesn't transmit to anyone and everyone who may be listening in, intentionally or unintentionally, this seems to be one of the best choices to make.  Your scrambled voice will sound like Donald Duck on a regular analog 46-49 mhz cordless phone or radio scanner, so it's at least a moderate roadblock for the average signal interceptor.  However, why on earth there is no 900 mhz (or higher) digital-spread-spectrum baby monitor on the market is beyond me.  So, this unit is one of the better compromises out there, and at ... on amazon.com, it is amazingly affordable. 

Only being able to compare this product with an old Fisher Price monitor I can say that this monitor is crystal clear. The old Fisher Price one gave out a constant fussy hum and picked up far to much noise around the room (eg the wind blowing past our windows). I'm confused though about the packaging between this Graco Ultra Clear Monitor and with the 'Graco Clear Range Monitor' the only apparent difference being 'microchip technology' while both are using 'telephone technology'. However I guess the extra $10 is worth it because this is definately crystal clear, without hissing and without interference. It genuinely only picks up our babies sounds. It is not interfering with our 2.4Ghz cordless phone and I have no idea about the review which says 'it's too loud'. Turn the volume all the way up and only when you put a monitor to your ear can you hear hissing, which is why you only need the volume set down to 2 or 3 (out of 4). It has two channels and so far I've not even had need to try a different channel due to static or interference. Who needs 2.4Ghz monitors (for greater range) like the Sony one- unless you plan on mowing the grass outside while monitoring? And the advantage here is you're provided with two monitors not just one. 

I am currently looking for a monitor for our second child.  We bought this one for our first child 2 years ago.  We thought we were buying quality, but this thing started getting more static at 3 months...then [just like the reader from MA] it stopped working completely.  What a waste of money!! 

Love this monitor!  This monitor is so clear... I can hear my baby move in his crib and the base is across the room from his crib.  From the day we brought him home from the hospital we have used this monitor and it has never failed us!  We recently traveled to another state to visit friends and took the monitor to use while we were there... our friends live in a condo complex with a pool.  This monitor worked from the pool... which was 4 units away from their unit and on the opposite side of the building.  (Don't worry... my friend was in the kitchen the whole time because her kids were sleeping in another room.)  My friends were so impressed that they gave away their monitor after we left and bought a GRACO Ultra Clear Monitor to use for their two boys.  So glad we have this one!  Highly recommend!!! 

I can't tell you how clear this monitor is!  I could hear my preemie baby sucking his pacifier with the base across the room from his crib, and that's not even something I normally hear when I'm with him.  Having two receivers is wonderful, I don't have to move one from room to room depending on where I'll be.  And not having batteries in the base really doesn't matter, because if the electricity is out, there's nothing else in the house to make noise that would prevent you from hearing baby.  It's not interrupted by our high powered cordless phones or the video monitor, either.  I highly recommend it! 

After reading the reviews I was very worried about all of the problems I read about.  I have not however encountered any of these with this monitor.  This monitor comes in very clear you can even hear the baby breathing!  I like the dual monitors I leave one in a stationary location and the other I carry around with me.  This way I have one on with the electricity but can also use a battery in the mobile one.  Once I read the reviews and decided on this monitor I did have trouble finding it.  I found it at Target.  I would definitly buy this product again. 

I'm a fan of Graco products in general, and this monitor does not disappoint.  The base is very sensitive, so it transmits even the smallest sounds from your baby's room.  The dual receivers work even when on different floors from the transmitter - in our 3-level, 2,400 sq ft house there's no spot I've found that doesn't get reception.  Best of all, the frequency doesn't cross our phones, computer network or any of our other electronics.  Highly recommended!! 

After trying 2 other monitors, this one is wonderful.  It gets great reception inside and out (I can get some yard work done!).  I have a 2-story house with a basement and get reception on all 3 levels.  Excellent product! 

First the pros:1.  The range on this monitor is fabulous.  We can pick up the sound from five houses away, down a city block.  All I really wanted to do was get a good signal deep in the backyard; this monitor has made it possible to take my toddler outside while the baby sleeps in his crib.2. I really like the graduated lights - green, yellow and red.  If there is some background noise in your room and you're not sure what you heard, the progressive lights help to confirm activity.3. I LOVE the portability! When packing up baby to go to a friends' house, there is no need to bring any power supplies!4. The manufacturer has great service.Now the bad:  It's true...this monitor stinks, mechanically.1. Upon opening the box, the parent unit picked up no sound, and the charging stand for the child unit did not light up, giving me no assurance that the child unit was being powered by the power supply.  A call to the manufacturer resulted in no-fuss delivery of new parts.2. Now, 6 months later, one of the child unit channels has gone defunct.  There are two channels, and we're using the only remaining channel.  Not comforting.  I will call the manufacturer again, not sure what the warranty is.Even if they do replace the latest part that has malfunctioned, it's hard for me to recommend this monitor despite the pluses. However, I hope they keep sending me replacement parts, because I really like the features of this monitor! 

I have had my monitor for 8 months now and I love it!! I have had no probelms with it what-so-ever! The best feature is the portable baby unit that attaches to her crib. I don't know what you'd do without that! So conveinent! I keep it on the charger durring the day, and attach it to her crib at night. It lasts all night, and the few times I've forgotten to turn it off and put it back in the morning, it's still working off the charger that next night! I do wish the parent unit was like this too, however, I haven't found it necessary...only for my own forgetful conveinence!I leave the parent unit plugged in by my bedside, but the few times I've used the battery and walked with it clipped to me, it was very easy, well heard, never cut in and out, and lasted a long time.I like the light gaging system too. As she is getting older, she has fussed more in her sleep without it being a true wake. Therefore, I can turn the monitor down low enough that the sleeping noises she makes do not keep me up all night, but if she truly wakes, I can hear it and look up to see I'm not dreaming! (which I have done quite a few times!) It's also nice if you are entertaining and purhaps, watching a movie. Being able to monitor the baby with the lights, without the interuptions of a noisy monitor is very nice. However, if you want to turn it up and hear every breath, it is very sensitive, and works this way attached to the crib rail no problem!I am very happy with this monitor and only hope it lasts for all the children I plan to have. I reccomend it to all my friends! 

Process reviews for the most common product

First, we define the aspects (product properties) of our current interest:


In [9]:
aspects = ['audio', 'price', 'signal', 'range', 'battery life']

In [10]:
item_a = 'Snuza Baby Monitor, Hero'
reviews_a = nlp_pipeline(reviews, item_a, aspects)


Snuza Baby Monitor, Hero
1. Get reviews for this product
2. Splitting reviews into sentences
3. Tagging relevant reviews
4. Extracting adjectives
5. Predicting sentence-level sentiment

In [11]:
reviews_a


Out[11]:
sentence_id sentence tag score name
23 I know from experience
that just seconds can ...
range 0.333333333333 Snuza Baby Monitor, Hero
44 If the battery lasted
longer or was easier to ...
battery life 0.545454545455 Snuza Baby Monitor, Hero
45 It works great and no
false alarms but it only ...
battery life 0.454545454545 Snuza Baby Monitor, Hero
71 The big problem for me
was after the first ...
battery life 0.333333333333 Snuza Baby Monitor, Hero
72 I even tried to order one
directly from snuza ( ...
battery life 0.454545454545 Snuza Baby Monitor, Hero
74 While it works perfect
when powered and the ...
battery life 0.357142857143 Snuza Baby Monitor, Hero
122 As a note for future
purchasers, read the ...
audio 0.333333333333 Snuza Baby Monitor, Hero
123 The audible sound really
helps when the kid is in ...
audio 0.333333333333 Snuza Baby Monitor, Hero
184 That, and the price was
right. ...
price 1.0 Snuza Baby Monitor, Hero
199 But it was well worth the
price for peace of mind. ...
price 1.0 Snuza Baby Monitor, Hero
review rating cleaned adjectives sentiment
After having a premature
baby and dealing with ...
5.0 baby {'ADJ': {}} 0.9997403422
If the battery lasted
longer or was easier to ...
2.0 battery lasted replace {'ADJ': {}} 0.298620364169
If the battery lasted
longer or was easier to ...
2.0 works great lasted
battery replacement ...
{'ADJ': {'great': 1}} 0.505285839252
We loved the simplicity
of the snuza! We decided ...
4.0 battery days so. {'ADJ': {}} 0.892817399817
We loved the simplicity
of the snuza! We decided ...
4.0 snuza days battery lasted {'ADJ': {'snuza': 1}} 0.717654362621
We loved the simplicity
of the snuza! We decided ...
4.0 works angelcare angelcare
battery ...
{'ADJ': {'angelcare': 1}} 0.813893110374
Whether it is just a
placebo or not, putting ...
5.0 make make audible baby {'ADJ': {'audible': 1}} 0.994484337495
Whether it is just a
placebo or not, putting ...
5.0 audible {'ADJ': {'audible': 1}} 0.990220531471
As new, first-time
parents, we were 99.9% ...
5.0 price {'ADJ': {}} 0.986437008533
Fabulous item. I'm a
first time mom, my ...
5.0 worth price {'ADJ': {'worth': 1}} 0.995479033113
[28 rows x 10 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.


In [12]:
reviews_a.save('./reviews_a')

Comparing to another product


In [13]:
dropdown = get_dropdown(reviews)
display(dropdown)

In [14]:
reviews_a = gl.load_sframe('./reviews_a/')
item_b = dropdown.value
print 'Comparing reviews with \'%s\':\n' % item_b
reviews_b = nlp_pipeline(reviews, item_b, aspects)


Comparing reviews with '900mhz Attachable Monitor':

900mhz Attachable Monitor
1. Get reviews for this product
2. Splitting reviews into sentences
3. Tagging relevant reviews
4. Extracting adjectives
5. Predicting sentence-level sentiment

In [15]:
counts, sentiment, adjectives = get_comparisons(reviews_a, reviews_b, item_a, item_b, aspects)

Comparing the number of sentences that mention each aspect:


In [16]:
counts


Out[16]:
tag Snuza Baby Monitor, Hero 900mhz Attachable Monitor
range 9 2
battery life 10 2
[2 rows x 3 columns]

Comparing the sentence-level sentiment for each aspect of each product:


In [17]:
sentiment


Out[17]:
tag Snuza Baby Monitor, Hero 900mhz Attachable Monitor
range 0.886754343263 0.998293848302
battery life 0.818302501793 0.999957300469
[2 rows x 3 columns]

Comparing the use of adjectives for each aspect:


In [18]:
adjectives


Out[18]:
tag Snuza Baby Monitor, Hero 900mhz Attachable Monitor
range [hard, snuza, angelcare] [aaas]
battery life [great, snuza, angelcare] [aaas]
[2 rows x 3 columns]

Investigating good and bad sentences


In [19]:
good, bad = get_extreme_sentences(reviews_a)

Print good sentences for the first item, where adjectives and aspects are highlighted.


In [20]:
print_sentences(good['highlighted'])


I was hesitant about the price, but bit the bullet and could not be happier.

The Hero has been great for our baby because she likes to sleep in her fisher price rock and play sleeper, so I can just attach it to her diaper at night and rest easy.

The reason I chose the Snuza style monitor over an Angel Care style monitor is because of size and portability.

We originally were given an angelcare monitor, but couldn't use the hard mat b/c our baby slept in a contoured Newborn Nappy in his Pack n Play for the first 2 months or so.

Worth the price for sure

But it was well worth the price for peace of mind.

As a note for future purchasers, read the instructions carefully to know what the blinking lights mean, and how to make it both blink and make an audible click every time the baby breathes.

I was hesitant at first to purchase this item because of it's price tag, but now that we have one, I'd never go without it.

The audible sound really helps when the kid is in his straight-jacket...errr....swaddle.

We set up our room with an Arms Reach co-sleeper and and Angelcare motion mat before our son was born.

While it works perfect when powered and the mobility of it is better than angelcare I don't think I would reccomend this over the angelcare because of the battery issue.

I even tried to order one directly from snuza (took 11 days to get) and it was just a generic battery that lasted a week.

It works great and no false alarms but it only lasted a week before it started beeping the battery was low and I haven't found a replacement at any local stores.

Print bad sentences for the first item, where adjectives and aspects are highlighted.


In [21]:
print_sentences(bad['highlighted'])


It works great and no false alarms but it only lasted a week before it started beeping the battery was low and I haven't found a replacement at any local stores.

I even tried to order one directly from snuza (took 11 days to get) and it was just a generic battery that lasted a week.

While it works perfect when powered and the mobility of it is better than angelcare I don't think I would reccomend this over the angelcare because of the battery issue.

We set up our room with an Arms Reach co-sleeper and and Angelcare motion mat before our son was born.

The audible sound really helps when the kid is in his straight-jacket...errr....swaddle.

I was hesitant at first to purchase this item because of it's price tag, but now that we have one, I'd never go without it.

As a note for future purchasers, read the instructions carefully to know what the blinking lights mean, and how to make it both blink and make an audible click every time the baby breathes.

But it was well worth the price for peace of mind.

Worth the price for sure

We originally were given an angelcare monitor, but couldn't use the hard mat b/c our baby slept in a contoured Newborn Nappy in his Pack n Play for the first 2 months or so.

The reason I chose the Snuza style monitor over an Angel Care style monitor is because of size and portability.

The Hero has been great for our baby because she likes to sleep in her fisher price rock and play sleeper, so I can just attach it to her diaper at night and rest easy.

I was hesitant about the price, but bit the bullet and could not be happier.

Summarizing sentiment with GLC product_sentiment.create()

One can even summarize the sentiment of the baby monitor's reviews (reviews) by utilizing the GraphLab Create's product_sentiment toolkit. The toolkit enables to search for aspects of interest (e.g. product properties) and obtain summaries of the reviews or sentences with the most positive (or negative) predicted sentiment.

Note, that since no target variable is given a pre-trained model will be used.


In [25]:
reviews_sentiment = gl.product_sentiment.create(reviews, 
                                                target=None,
                                                features=['review'], 
                                                method='auto',
                                                splitby='review')


WARNING: Column '__review_id' is excluded due to invalid column type (integer).
WARNING: Column 'sentiment_score' is excluded due to invalid column type (float).
Tokenizing...
TF-IDF transform...
Creating inverted index...
Creating query expansion model...
Saving data for querying...

To get an overview of the top-10 reviews for every product property in the aspects list below:


In [26]:
print aspects


['audio', 'price', 'signal', 'range', 'battery life']

we make the call:


In [27]:
reviews_sentiment.sentiment_summary(keywords=aspects, groupby='name', k=10, threshold=3)


Out[27]:
keyword name mean_sentiment sd_sentiment review_count
battery life Snuza Baby Monitor, Hero 0.663579537023 0.322874099963 7
price Snuza Baby Monitor, Hero 0.977244026731 0.0140913309791 4
price Fisher-Price Aquarium
Monitor ...
0.305380831961 0.196483541825 4
range Samsung Ezview Baby
Monitor ...
0.626363802641 0.347454141285 4
[4 rows x 5 columns]

Note, that we have grouped the result by the product 'name' but we have limit summaries to only those having at least three (3) of product reviews.

Under the hood

While creating the model, several operations are completed under the hood:

  • A data structure is created that helps facilitate searching for text snippets, including doing a TF-IDF transform of the text and creating an inverted index.
  • Each piece of text is tokenized into sentences using NLTK's punkt sentence parser.
  • A pre-trained sentiment classifier scores all reviews (or sentences) and stores these scores within the model.

Providing a splitby='sentence' argument when training the model implies that all analysis should be performed at the sentence-level rather than using the entire text. Thus any calls to sentiment_summary() will concern predictions for each sentence rather than the entire review.


In [28]:
reviews_sentiment1 = gl.product_sentiment.create(reviews, 
                                                 target=None,
                                                 features=['review'], 
                                                 method='auto',
                                                 splitby='sentence')


2016-05-25 19:07:35,629 [INFO] graphlab.toolkits.product_sentiment._product_sentiment, 184: Parsing into sentences...
WARNING: Column '__review_id' is excluded due to invalid column type (integer).
WARNING: Column 'rating' is excluded due to invalid column type (float).
WARNING: Column 'sentiment_score' is excluded due to invalid column type (float).
Tokenizing...
TF-IDF transform...
Creating inverted index...
Creating query expansion model...
Saving data for querying...

In [29]:
reviews_sentiment1.sentiment_summary(keywords=aspects, groupby='name', k=10, threshold=3)


Out[29]:
keyword name mean_sentiment sd_sentiment review_count
battery life Snuza Baby Monitor, Hero 0.727998238382 0.245665347379 8
price Snuza Baby Monitor, Hero 0.914072266226 0.047479861396 6
range Samsung Ezview Baby
Monitor ...
0.668630512222 0.343785782504 4
[3 rows x 5 columns]

To have an overview of the internal sentiment model used:


In [37]:
reviews_sentiment1.sentiment_scorer


Out[37]:
Class                           : SentimentAnalysisModel

Data
----
Number of rows                  : 98

Model
-----
Score column                    : None
Features                        : ['review']
Method                          : bow-logistic

To have an overview of the model that searches for text snippets:


In [38]:
reviews_sentiment1.review_searcher


Out[38]:
Class                           : SearchModel

Corpus
------
Number of documents             : 670
Average tokens/document         : {'review': 17.523880597014927, 'name': 3.952238805970149, 'sentence': 17.523880597014927}

Indexing settings
-----------------
BM25 k1                         : 1.5
BM25 b                          : 0.75
TF-IDF threshold                : 0.01

Index
-----
Number of unique tokens indexed : 1751
Preprocessing time (s)          : 1.3147
Indexing time (s)               : 0.7337